//
//  VerticalStackView.swift
//  SwiftUI-CTao
//
//  Created by 涛 on 2019/9/17.
//  Copyright © 2019 涛. All rights reserved.
//

import SwiftUI

struct VerticalStackView: View {
    
    @State var alignment: HorizontalAlignment = .center

    var body: some View {
        /*
         /// A guide marking the leading edge of the view.
         public static let leading: HorizontalAlignment

         /// A guide marking the horizontal center of the view.
         public static let center: HorizontalAlignment

         /// A guide marking the trailing edge of the view.
         public static let trailing: HorizontalAlignment
         */
        VStack {
            
            VStack(alignment: alignment, spacing: 10) {
                Text("垂直布局垂直布局垂直布局垂直布局垂直布局垂直布局垂直布局垂直布局")
                Image("5")
                    .resizable()
                    .frame(width: 200, height: 200)
                Text("试试效果就行了")
            }
            
            Spacer()
            Text("试试下面的按钮⬇️")
            
            HStack {
                Button(action: {self.alignment = .leading}) {
                    Text("leading")
                }
                Button(action: {self.alignment = .center}) {
                    Text("center")
                }
                Button(action: {self.alignment = .trailing}) {
                    Text("trailing")
                }
            }
            
        }
    }
}

struct VerticalStackView_Previews: PreviewProvider {
    static var previews: some View {
        VerticalStackView()
    }
}
